<?php

class Corpus{
 protected $id;
 protected $array_document;

 public function __construct($_id='', $_array_document=array()){
  $this->id=$_id;
  $this->array_document=$_array_document;
 }

 public function get_id(){
  return $this->id;
 }
 public function get_array_document(){
  return $this->array_document;
 }
 public function get_document($_id_doc){
  return $this->array_document[$_id_doc];
 }

 public function push_document($_doc,$_id=null){
  if($_id != null and isset($this->array_doc[$_id])){
    die('Corpus::push_document ID_ALREADY_USED');
  }
  if($_id == null){
    $this->array_document[] = $_doc;
  }
  else{
    $this->array_document[$_id] = $_doc;
  }
 }

  public function push_array_document($_array_doc){
    foreach($_array_doc as $document){
      $this->push_document($document);
    }
  }

  public function init($_path_dir){
    $this->id = $_path_dir;
    $all_files = Tool_dir::get_files($_path_dir);
    foreach($all_files as $pathfile){
      $document = new Document();
      $document->init($pathfile);
      $this->array_doc[] = $document;
    }
  }

}
?>
